<?php
session_start();
include('inc/connection.php');

?>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <meta name="Hasan" content="EC" />
        <!--  CSS   -->
        <link href="css/en/mycss.css" rel="Stylesheet" type="text/css" />
        <link href="css/en/header.css" rel="Stylesheet" type="text/css" />
        <link href="css/en/footer.css" rel="Stylesheet" type="text/css" />
        <link href="css/en/history.css" rel="Stylesheet" type="text/css" />
        <link rel="shortcut icon" href="favicon.ico" />
        <!--  JS   -->
        <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
        <script src="js/myjs.js"></script>
        <script src="js/history.js"></script>
        <script src="js/header.js"></script>

        <title>Mobizoo Mobiles</title>
    </head>

    <!-- BODY -->
    <body>

        <!-- ********************************* -->
        <!-- header -->
        <!-- ********************************* -->
        <?php
        include('inc/header.php');
        ?>

        <!-- ********************************* -->
        <!-- history -->
        <!-- ********************************* -->
        <div id="historyContainer">
            <div id="historyProductsArea">
                <div id="historyProductsAreaTitle">
                    <img src="images/history.png"/>
                    <h2>History Items</h2>
                </div>
                <?php
//                echo $_SESSION['id'];
                if (!isset($_SESSION['id'])) {
                    echo '<p>login to pruchase</p>';
                } else {

                    $sql1 = "SELECT * FROM `bought_product` WHERE bought_product.userID =  " . $_SESSION['id'];
                    $result1 = mysql_query($sql1);
                    $cartActive = mysql_num_rows($result1);
                    
//                    echo mysql_num_rows($result);
                    while ($row1 = mysql_fetch_array($result1)) {
                        $sql = "SELECT * FROM `products` WHERE id = " . $row1['productID'] ;
                        $result = mysql_query($sql);
                        $row = mysql_fetch_array($result);
                       $price = $row['price'];
                        
                        echo '<div  class="historyProductsAreaSlices">
                                <div class="historyProductsAreaSlicesImage">
                                    <img src="../photos/thumb/' . $row['img'] . '" height="90%"/>
                                </div>
                                <div class="historyProductsAreaSlicesInfo">
                                    <div class="historyProductsAreaSlicesInfoTitle">
                                        <h3>' . $row['name_en'] . '</h3>
                                    </div>
                                    <div class="historyProductsAreaSlicesInfoDesc">
                                        <p> ' . $row['desc_en'] . ' </p>
                                    </div>
                                    <div class="historyProductsAreaSlicesInfoPrice">
                                        <p class="price">||Price: ' . $price . '</p>
                                        <p class="totalPrice">||Quantity: ' . $row1['quantity'] . '</p>
                                        
                                        <div class="historyProductsAreaSlicesInfoPriceButtons">
                                            <p>'.$row1['buy_date'].'</p>
                                        </div>
                                    </div>

                                </div>
                            </div>';
                    }
                    if ($cartActive == 10) {
                        if($language=='en'){
                            echo '<div id="cartProductsAreaPerform">
                            <p style="display:block; margin:auto; width:180px; text-align:center; background-color:brown;color:white; border-radius:5px;">Your History Is Empty ^^</p>
                            </div>';
                        }else{
                            echo '<div id="cartProductsAreaPerform">
                            <p style="display:block; margin:auto; width:180px; text-align:center; background-color:brown;color:white; border-radius:5px;">سجلك فارغ ^^</p>
                            </div>';
                        }
                        
                    } else {
                        
                    }
                }
                ?>
            </div>
        </div>

        <!-- ********************************* -->
        <!-- footer -->
        <!-- ********************************* -->
        <?php
        //include('inc/footer.php');
        ?>

    </body>
</html>